package com.tanhua.back.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tanhua.back.entity.Log;
import com.tanhua.back.mapper.LogMapper;
import com.tanhua.back.service.LogService;
import com.tanhua.back.vo.LogVo;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, Log> implements LogService {
    /**
     * 分页查询数据
     *
     * @param uid
     * @param page
     * @param pagesize
     * @param type
     * @return
     */
    @Override
    public Page getPage(Long uid, Integer page, Integer pagesize, String type) {
        //1.设置分页参数
        Page ipage = new Page(page,pagesize);

        //2.设置查询条件
        LambdaQueryWrapper<Log> wrapper = new LambdaQueryWrapper();
        wrapper.eq(Log::getUserId,uid)
                .eq(Log::getType,type)
                .orderByDesc(Log::getCreated);

        this.page(ipage,wrapper);
        return ipage;
    }
}
